<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	template="/templates/layout.xhtml">
		
	<ui:define name="head">	</ui:define>

	<ui:define name="ptitle">采购订单查询</ui:define>
	
	<ui:define name="pcontent">
		
	<h:form id="frm6"> 
		<h:panelGrid columns="10" cellspacing="10">	
			<p:outputLabel value="订单编号" />
			<p:inputText  value="#{purchQueryMB.io.id}" />
			<p:outputLabel value="合同名称" />
			<p:inputText value="#{purchQueryMB.io.contName}" />
			<p:outputLabel value="供应商" />
			<p:inputText value="#{purchQueryMB.io.bmeSupplier.name}" />
 			<p:outputLabel value="收货人" />
			<p:inputText value="#{purchQueryMB.io.consignee}" />
			<p:outputLabel value="订单状态" />
			<p:selectOneMenu value="#{purchQueryMB.io.status}" effect="fold" style="width:80%;"> 
				<f:selectItems value="#{purchQueryMB.itemsPurchStatus}" />
			</p:selectOneMenu>	
			<p:outputLabel value="订单日期" />
			<p:calendar id="stime" locale="zh" navigator="true" value="#{purchQueryMB.beginTime}" 
				pattern="yyyy-MM-dd" mask="true"  mode="popup"	showOn="button" popupIconOnly="true"/>
			<h:outputText for="etime" value="------------" />
			<p:calendar id="etime"  locale="zh" navigator="true" value="#{purchQueryMB.endTime}" 
				pattern="yyyy-MM-dd" mask="true"  mode="popup"	showOn="button" popupIconOnly="true"/>				
				
            <p:commandButton value="查询"	icon="ui-icon-search"  
				action="#{purchQueryMB.queryAction}"  update=":frm7 ">
			</p:commandButton>		
		</h:panelGrid>
	</h:form>

	<h:form id="frm7">
		<p:growl id="msgs1" showDetail="true" />
		<p:panel id="contPanel" header="订单信息" style="margin-bottom:5px">
			
			<p:dataTable id="pdt" value="#{purchQueryMB.voc}"  var="prow"  rowIndexVar="prowNum"
				style="margin-bottom:5px"
				selectionMode="single" selection="#{purchQueryMB.selectedd}" rowKey="#{prow.id}"
				scrollable="true" scrollWidth="98%"  emptyMessage="没有记录" 
				paginator="true" paginatorPosition="bottom" rows="8" 
	 			paginatorTemplate="{Exporters}  {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} " >
				
				<f:facet name="{Exporters}">
		            <h:commandLink title="导出XLS">
		                <p:graphicImage name="/images/xls.png" width="16" height="16"/>
		                <p:dataExporter type="xls" target="pdt" fileName="purchOrders" />
		            </h:commandLink>		 
		        </f:facet>
				<p:ajax event="rowSelect" listener="#{purchQueryMB.onPurchSelected}" update=":frm7:detailPanel" />		
		
				<p:column headerText="No."  width="20" exportable="false" >#{prowNum+1}</p:column>
				
				<p:column headerText="订单编号"  width="100" sortBy="#{prow.id}">
					<h:outputText value="#{prow.id}" />
				</p:column>
				<p:column headerText="订单日期" width="100" >
					<h:outputText value="#{prow.orderDate}" >
						<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" />
					</h:outputText>
				</p:column>
				<p:column headerText="合同名称" width="100" >
					<h:outputText value="#{prow.contName}" />
				</p:column>
				<p:column headerText="供货商" width="100" >
					<h:outputText value="#{prow.bmeSupplier.name}" />
				</p:column>
				<p:column headerText="收货人" width="100" >
					<h:outputText value="#{prow.consignee}" />
				</p:column>
				<p:column headerText="收货地址" width="100" >
					<h:outputText value="#{prow.shippingAddress}" />
				</p:column>
				<p:column headerText="电话" width="100" >
					<h:outputText value="#{prow.phone}" />
				</p:column>
				<p:column headerText="订单状态" width="100" >
					<p:selectOneMenu value="#{prow.status}"  disabled="true"	>
						<f:selectItems value="#{purchQueryMB.itemsPurchStatus}" />
					</p:selectOneMenu>				
				</p:column>
				<p:column headerText="备注" width="100" >
					<h:outputText value="#{prow.remarks}" />
				</p:column>
				<p:column headerText="订单金额" width="100" >
					<h:outputText value="#{prow.amount}" />
				</p:column>
				<p:column headerText="已发货额" width="100" >
					<h:outputText value="#{prow.shippedAmount}" />
				</p:column>
				<p:column headerText="未发货额" width="100" >
					<h:outputText value="#{prow.unshippedAmount}" />
				</p:column>
				
			</p:dataTable>
							
		</p:panel>
		<p:panel id="detailPanel">
			<p:dataTable id="ddt" value="#{purchQueryMB.vod}"  var="row"  rowIndexVar="rowNum"
				resizableColumns="true" liveResize="true" 
				scrollable="true" scrollWidth="97%" 
				style="margin-bottom:5px" emptyMessage="没有记录" 
				paginator="true" paginatorPosition="bottom" rows="8" 
	 			paginatorTemplate="{Exporters}  {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} " >
				
				<f:facet name="{Exporters}">
		            <h:commandLink title="导出XLS">
		                <p:graphicImage name="/images/xls.png" width="16" height="16"/>
		                <p:dataExporter type="xls" target="ddt" fileName="orderDetails" />
		            </h:commandLink>		 
		        </f:facet>
				
				<f:facet name="header">订单采购信息</f:facet>

				<p:column headerText="No." width="20" exportable="false">
					#{rowNum+1}
				</p:column>
				<p:column headerText="物料编号" sortBy="#{row.bmeMaterial.id}" width="100" >
					<h:outputText value="#{row.bmeMaterial.id}" />
				</p:column>
				<p:column headerText="物料描述" width="100" >
					<h:outputText value="#{row.bmeMaterial.mdesc}" />
				</p:column>
				<p:column headerText="数量" width="100" >
					<h:outputText value="#{row.mquantity}" />
				</p:column>

				<p:column headerText="单价" width="100" >
					<h:outputText value="#{row.mprice}" />
				</p:column>
				<p:column headerText="金额" width="100" >
					<h:outputText value="#{row.mamount}" />
				</p:column>
				<p:column headerText="安装区域" width="100" >
					<h:outputText value="#{row.area}" />
				</p:column>
				<p:column headerText="总金额" width="100" >
					<h:outputText value="#{row.amount}" />
				</p:column>					
				<p:column headerText="已发货数量" width="100" >
					<h:outputText value="#{row.squantity}" />
				</p:column>
				<p:column headerText="未发货数量" width="100" >
					<h:outputText value="#{row.mquantity - row.squantity}" />
				</p:column>
				<p:column headerText="要求交期" width="100" >
					<h:outputText value="#{row.requiredDate}" >
						<f:convertDateTime pattern="yyyy-MM-dd" />
					</h:outputText>						
				</p:column>
				<p:column headerText="反馈交期" width="100" >
					<h:outputText value="#{row.respDate}" >
						<f:convertDateTime pattern="yyyy-MM-dd" />
					</h:outputText>						
				</p:column>				
				<p:column headerText="反馈备注" width="100" >
					<h:outputText value="#{row.respRemarks}" />
				</p:column>									
				<p:column headerText="备注" width="100" >
					<h:outputText value="#{row.remarks}" />
				</p:column>
				<p:column headerText="加工工艺" width="100" >
					<h:outputText value="#{row.processTeck}" />
				</p:column>	
				<p:column headerText="加工规格" width="100" >
					<h:outputText value="#{row.processSpeci}" />
				</p:column>					
				<p:column headerText="每片加工量" width="100" >
					<h:outputText value="#{row.processFactor}" />
				</p:column>					
				<p:column headerText="加工总量" width="100" >
					<h:outputText value="#{row.processSum}" />
				</p:column>					
				<p:column headerText="数量-片" width="100" >
					<h:outputText value="#{row.processQuantity}" />
				</p:column>	
				<p:column headerText="加工单价" width="100" >
					<h:outputText value="#{row.processPrice}" />
				</p:column>					
				<p:column headerText="加工单位" width="100" >
					<h:outputText value="#{row.processUnit}" />
				</p:column>	
				<p:column headerText="加工费用" width="100" >
					<h:outputText value="#{row.processAmount}" />
				</p:column>					
				
			</p:dataTable>
   
		</p:panel>
		
	</h:form>
	
	</ui:define>
</ui:composition>
